package edu.nf.ch02.service;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.HashMap;
import java.util.Map;

/**
 * @author wangl
 * @date 2025/4/27
 */
public class Main {

    public static void main(String[] args) throws Exception {
        ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
        UserService s1 = context.getBean(UserService.class);
        UserService s2 = context.getBean(UserService.class);
        System.out.println(s1);
        System.out.println(s2);

        Class<?> clazz = Class.forName("edu.nf.ch02.service.impl.UserServiceImpl");

        //singleTonMap
        /*Map<String, Object> singleTon = new HashMap<>();
        Object object = clazz.getConstructor() .newInstance();
        singleTon.put("userService", object);*/

        //prototype的map
        /*Map<String, Class<?>> prototypeMap = new HashMap<>();
        prototypeMap.put("userService", clazz);
        Class<?> beanClass = prototypeMap.get("userService");
        beanClass.getConstructor().newInstance();*/
    }
}